package com.da.javatest.leetCode;

/**
 * @author chenlida
 * @date 2018/12/17 14:56
 * @description
 */
public class Code226 {
    public TreeNode invertTree(TreeNode root) {
        if (root == null) { return null; }
        if (root.left != null || root.right != null) {
            TreeNode temp = root.right;
            root.right = root.left;
            root.left = temp;
        }
        root.left = invertTree(root.left);
        root.right = invertTree(root.right);
        return root;
    }
}
